var averageOfLevels = function(root) {
    const arr = []
    const fnc = (node,h) => {
        if(!node) return
        if(!arr[h]) arr[h] = []
        arr[h].push(node.val)
        fnc(node.left,h+1)
        fnc(node.right,h+1)
    }
    fnc(root,0)
    return arr.map(i=>i.reduce((a,b)=>a+b,0)/i.length)
};
let n = averageOfLevels([3,9,20,null,null,15,7])